<?php
include('admin.php');
get_header();

if (file_exists('install.php')) @unlink('install.php');
if (file_exists('install.php')) {
?>
		<p class="error"><strong>Error:</strong> Please manually delete install.php.</p>
<?php
}

if (file_exists('upgrade.php')) @unlink('upgrade.php');
if (file_exists('upgrade.php')) {
?>
		<p class="error"><strong>Error:</strong> Please manually delete upgrade.php.</p>
<?php
}

$comments = get_comments(array('perpage'=>5, 'paginationVar'=>'comments'));
$posts = get_posts(array('perpage'=>5, 'paginationVar'=>'posts'));
?>
		<div class="box">
			<h2>Recent Comments</h2>
			<table class="comments" width="100%">
				<thead>
					<tr>
						<th>Comment</th>
					</tr>
				</thead>
				<tfoot>
					<tr>
						<td>
							Page: <?php echo $comments->pagination['page']; ?><?php if ($comments->needsPagination()) { echo ' &mdash; '; $comments->pagination(); } ?>
						</td>
					</tr>
				</tfoot>
				<tbody>
<?php
if ($comments->total > 0) {
	foreach($comments->items as $comment) {
?>
					<tr<?php $comment->the_row_info(); ?>>
						<td>
							<?php $comment->the_content(); ?>
							<p class="right"><?php $comment->the_author_link(); ?> &middot; <?php $comment->the_options(); ?></p>
						</td>
					</tr>
<?php
	}
} else {
?>
					<tr>
						<td>No comments found.</td>
					</tr>
<?php
}
?>
				</tbody>
			</table>
		</div>
		
		<div class="box second-box">
			<h2>Recent Posts</h2>
			<table class="comments" width="100%">
				<thead>
					<tr>
						<th>Title</th>
						<th>Date</th>
						<th class="center">Comments</th>
						<th>&nbsp;</th>
					</tr>
				</thead>
				<tfoot>
					<tr>
						<td colspan="4">
							Page: <?php echo $posts->pagination['page']; ?><?php if ($posts->needsPagination()) { echo ' &mdash; '; $posts->pagination(); } ?>
						</td>
					</tr>
				</tfoot>
				<tbody>
<?php
if ($posts->total > 0) {
	foreach($posts->items as $post) {
?>
					<tr<?php $post->the_row_info(); ?>>
						<td><?php $post->the_title(); ?></td>
						<td><?php $post->the_date('n/j/y'); ?></td>
						<td class="center"><?php echo $post->get_comment_amount(''); ?></td>
						<td><?php $post->the_options(); ?></td>
					</tr>
<?php
	}
} else {
?>
					<tr>
						<td colspan="4">
							No posts found.
						</td>
					</tr>
<?php
}
?>
				</tbody>
			</table>
		</div>
		
		<br class="clear" />
<?php
get_footer();
?>